package cn.ekuma.pos.toolcommand.order;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;

import net.xeoh.plugins.base.annotations.PluginImplementation;

import com.openbravo.data.basic.BasicException;

import cn.ekuma.epos.toolcommand.AbstractCommand;
import cn.ekuma.epos.order.AbstractJOrderProcessPanel;

@PluginImplementation
public class OrderFormatCommand extends AbstractCommand{
	@Override
	public void call() throws BasicException {
		JDialog orderFormatDialog=new JDialog((Frame) getWindow((Component) app),true);
		orderFormatDialog.setLayout(new java.awt.BorderLayout());
		orderFormatDialog.add(new AbstractJOrderProcessPanel(app){

			@Override
			public void addCommand(JPanel commandPanel) {
					
			}
			
		},BorderLayout.CENTER);
		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		orderFormatDialog.setBounds((screenSize.width - 703) / 2, (screenSize.height - 645) / 2,703, 645);
		orderFormatDialog.pack();
		orderFormatDialog.setVisible(true);
	}

	@Override
	public String getCommandName() {
		return "单据格式工具";
	}

	@Override
	public String getCommandCategoryName() {
		return "单据";
	}

	protected static Window getWindow(Component parent) {
        if (parent == null) {
            return new JFrame();
        } else if (parent instanceof Frame || parent instanceof Dialog) {
            return (Window)parent;
        } else {
            return getWindow(parent.getParent());
        }
    }    
}
